home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 001a / foscom.zip / FOSCOM.ASI next >
Text File  |  1991-10-13  |  7KB  |  366 lines

  1.  
  2. parse$=command$
  3. GOSUB INITSYS:
  4. loop:
  5.    gosub sendbyte:
  6.    gosub getbyte:
  7. goto loop:
  8.  
  9. outloop:
  10.    GOSUB DTRDN:
  11.    GOSUB CLOSESYS:
  12. END
  13.  
  14. SETPORT:
  15.    ah=&hex0000
  16.    al=&hex03
  17.    al=baudrate
  18.    gosub fixax:
  19.    pt=&hex0014
  20.    INT86(&HEX14,AX,NA,NA,DX,NA,NA,NA,NA,NA)
  21. RETURN
  22.  
  23. ACTPORT:
  24.    ah=&hex04
  25.    al=&hex00
  26.    gosub fixax:
  27.    INT86(&HEX14,AX,BX,NA,DX,NA,NA,NA,NA,NA)
  28. RETURN
  29.  
  30. DEACTPORT:
  31.    ah=&hex05
  32.    al=&hex00
  33.    gosub fixax:
  34.    INT86(&HEX14,AX,NA,NA,DX,NA,NA,NA,NA,NA)
  35. RETURN
  36.  
  37. DTRUP:
  38.    ah=&hex06
  39.    al=&hex01
  40.    gosub fixax:
  41.    INT86(&HEX14,AX,NA,NA,DX,NA,NA,NA,NA,NA)
  42. RETURN
  43.  
  44. DTRDN:
  45.    ah=&hex06
  46.    al=&hex00
  47.    gosub fixax:
  48.    INT86(&HEX14,AX,NA,NA,DX,NA,NA,NA,NA,NA)
  49. RETURN
  50.  
  51. GETKEY:
  52.    A$=""
  53.    WHILE A$=""
  54.       A$=INKEY$
  55.    WEND
  56. RETURN
  57.  
  58. INITSYS:
  59.    esc$=chr$(27)
  60.    cr$=chr$(13)
  61.    lf$=chr$(10)
  62.    bs$=chr$(8)
  63.    exit$=chr$(45)
  64.    hangup$=chr$(35)
  65.    formfeed$=chr$(12)
  66.    pgdn$=chr$(81)
  67.    pgup$=chr$(73)
  68.    off = 0
  69.    on = 1
  70.    gosub parsit:
  71.    port$=par$
  72.    gosub parsit:
  73.    baud$=par$
  74.    baud=val(baud$)
  75.    GOSUB PARSIT:
  76.    handshake$=par$
  77.    if port$="" then
  78.       cls
  79.       print "You did not enter the port, baudrate, and handshake information.";
  80.       print "  If you ";
  81.       print "wish to do so from the command line, the syntax is:"
  82.       print
  83.       print "   COMIN P BAUD HANDSHAKE"
  84.       print
  85.       print "Where:"
  86.       print "         P is the Port Number (1 or 2)"
  87.       print "         BAUD the desired Baud Rate...and"
  88.       print "         HANDSHAKE is the desired Handshake type."
  89.       print "            (NONE, XON, CTS, or BOTH"
  90.       print
  91.       print "NOTE that pressing Alt-X drop DTR and exit this program."
  92.       print "          pressing Alt-H will drop DTR for 2 seconds (Hangup)."
  93.       print
  94.       print "--------------------------- MANUAL SETUP";
  95.       print " ---------------------------"
  96.       print
  97.       print "Port";
  98.       input port$
  99.    endif
  100.    if baud$="" then
  101.       print "Baud Rate";
  102.       input baud$
  103.    endif
  104.  
  105.    if handshake$="CTS" then
  106.       a$="3"
  107.    endif
  108.    if handshake$="XON" then
  109.       a$="2"
  110.    endif
  111.    if handshake$="NONE" then
  112.       a$="1"
  113.    endif
  114.    if handshake$=""then
  115.       PRINT "Handshake"
  116.       print " 1.  None"
  117.       print " 2.  XON/XOFF"
  118.       print " 3.  RTS/CTS"
  119.       print "     Any other choice selects BOTH!"
  120.       print "     Please make your selection...";
  121.       xon=on
  122.       cts=on
  123.       while a$=""
  124.          a$=inkey$
  125.       wend
  126.    else
  127.       if a$="1" then
  128.          xon=off
  129.          cts=off
  130.       endif
  131.       if a$="2" then
  132.          xon=on
  133.          cts=off
  134.       endif
  135.       if a$="3" then
  136.          xon=off
  137.          cts=on
  138.       endif
  139.       goto start:
  140.    endif
  141.    start:
  142.  
  143.    port=val(port$)
  144.    baud=val(baud$)
  145.    if port = 1 then
  146.       dx=&hex0000
  147.    else
  148.       dx=&hex0001
  149.    endif
  150.    baudrate=&bin00000000
  151.    if baud = 19200 then
  152.       baudrate=&bin00000011
  153.    endif
  154.    if baud = 9600 then
  155.       baudrate=&bin11100011
  156.    endif
  157.    if baud = 4800 then
  158.       baudrate=&bin11000011
  159.    endif
  160.    if baud = 2400 then
  161.       baudrate=&bin10100011
  162.    endif
  163.    if baud = 1200 then
  164.       baudrate=&bin10000011
  165.    endif
  166.    if baud = 600 then
  167.       baudrate=&bin01100011
  168.    endif
  169.    if baud = 300 then
  170.       baudrate=&bin01000011
  171.    endif
  172.  
  173.    cls
  174.    locate 1,26
  175.    print "Small FOSSIL Comm System"
  176.    GOSUB SETPORT:
  177.    GOSUB ACTPORT:
  178.    GOSUB HANDSHAKE:
  179.    GOSUB DTRUP:
  180. RETURN
  181.  
  182. CLOSESYS:
  183.    GOSUB DEACTPORT:
  184. RETURN
  185.  
  186. sendbyte:
  187.    k$=inkey$
  188.    if k$="" then around:
  189.    if extended = 1 then
  190.       gosub longstring:
  191.       goto around:
  192.    endif
  193.    al=asc(k$)
  194.    ah=&hex01
  195.    gosub fixax:
  196.    int86(&hex14,ax,na,na,dx,na,na,na,na,na)
  197.    around:
  198. return
  199.  
  200. longstring:
  201.    k$=right$(k$,1)
  202.    if k$=exit$ then
  203.       gosub quit:
  204.    endif
  205.    if k$=hangup$ then
  206.       gosub dtrdn:
  207.       tim=30
  208.       k$=""
  209.       gosub wait:
  210.       gosub dtrup:
  211.    endif
  212.    if k$=pgdn$ then
  213.       gosub download:
  214.    endif
  215.    if k$=pgup$ then
  216.       gosub upload:
  217.    endif
  218. return
  219.  
  220. download:
  221.    gosub commandenv:
  222.    call(envcheck$," /C zdown.bat")
  223. return
  224.  
  225. upload:
  226.    gosub commandenv:
  227.    print "File(s) to send:";
  228.    input files$
  229.    filesend$=" /C zup.bat "+files$
  230.    call envcheck$,filesend$)
  231. return
  232.  
  233. commandenv:
  234.    envcheck$="COMMAND.COM"
  235.    gosub envcheck:
  236.    envcheck$=envcheck$+"COMMAND.COM"
  237. return
  238.  
  239. envcheck:
  240.    loopit:
  241.    temp$=environ$(1)
  242.    temp$=ucase$(temp$)
  243.    templen=len(temp$)
  244.    if temp$="" then
  245.       envcheck$="c:\"
  246.       return
  247.    endif
  248.    templen = len(envcheck$)
  249.    temp = instr(temp$,envcheck$)
  250.    if temp = 0 then loopit:
  251.    templen1=len(temp$)
  252.    templen1=templen1-templen
  253.    temp$=left$(temp$,templen1)
  254.    temp = instr(temp$,"=")
  255.    temp1 = len(temp$)
  256.    temp1 = temp1-temp
  257.    envcheck$ = right$(temp$,temp1)
  258.    envcheck$=ltrim$(envcheck$)
  259. return
  260.  
  261. quit:
  262.    Print " Dropping DTR and exiting   "
  263.    Print "Is this REALLY what you want to do (Y/n)?  ";
  264.    gosub getkey:
  265.    a$=right$(a$,1)
  266.    a$=ucase$(a$)
  267.    if a$="Y" then
  268.       goto outloop:
  269.    else
  270.       cls
  271.    endif
  272. return
  273.  
  274. getbyte:
  275.    ax=&hex2000
  276.    int86(&hex14,ax,na,na,dx,na,na,na,na,na)
  277.    if ax=&hexFFFF then skip:
  278.    s$=chr$(ax)
  279.    if s$=lf$ then skip:
  280.    if s$=formfeed$ then
  281.       cls
  282.       goto skip:
  283.    endif
  284.    if s$=cr$ then
  285.       print ""
  286.    else
  287.    ax=&hex1300
  288.    al=asc(s$)
  289.    ax=ax+al
  290.    int86(&hex14,ax,na,na,na,na,na,na,na,na)
  291.    endif
  292.    skip:
  293. return
  294.  
  295. fixax:
  296.    ax=ah*&hex100
  297.    ax=ax+al
  298. return
  299.  
  300. fixal:
  301.    al=ax*&hex100
  302.    al=ax/&hex100
  303. return
  304.  
  305. fixah:
  306.    ah=ax/&hex100
  307. return
  308.  
  309. backspace:
  310.    x=pos(0)
  311.    y=csrlin
  312.    xx=x-1
  313.    if xx<0 then
  314.       y=y-1
  315.       xx=79
  316.       if y < 1 then
  317.          y=1
  318.          xx=0
  319.       endif
  320.    endif
  321.    locate y,xx
  322.    print " ";
  323.    locate y,xx
  324. return
  325.  
  326. wait:
  327. stime&=timer
  328. etime&=stime&+tim
  329. while stime& < etime&
  330.    stime&=timer
  331. wend
  332. return
  333.  
  334. handshake:
  335. al=&bin00000000
  336. if xon = on then
  337.    al=al+&bin00000001
  338. endif
  339. if cts=on then
  340.    al=al+&bin00000010
  341. endif
  342. if txxon=on then
  343.    al=al+&bin00001000
  344. endif
  345. ah=&hex0F
  346. gosub fixax:
  347. int86(&hex14,AX,na,na,dx,na,na,na,na,na)
  348. return
  349.  
  350. parsit:
  351. par$=""
  352. parse$=ltrim$(parse$)
  353. parse=len(parse$)
  354. if parse>0 then
  355.    tempspace=instr(parse$," ")
  356.    if tempspace < 1 then
  357.       tempspace=parse
  358.    endif
  359.    par$=left$(parse$,tempspace)
  360.    parse=parse-tempspace
  361.    parse$=right$(parse$,parse)
  362. endif
  363. par$=ucase$(par$)
  364. par$=rtrim$(par$)
  365. return
  366.